using System.Windows;
using System.Windows.Controls;
using LottieDemo.Models;

namespace LottieDemo.Converters;

/// <summary>
/// 消息模板选择器
/// </summary>
public class MessageTemplateSelector : DataTemplateSelector
{
    /// <summary>
    /// 用户消息模板
    /// </summary>
    public DataTemplate? UserTemplate { get; set; }

    /// <summary>
    /// AI消息模板
    /// </summary>
    public DataTemplate? AssistantTemplate { get; set; }

    public override DataTemplate? SelectTemplate(object item, DependencyObject container)
    {
        if (item is ChatMessage message)
        {
            return message.Type == MessageType.User ? UserTemplate : AssistantTemplate;
        }

        return base.SelectTemplate(item, container);
    }
}
